package com.system.service.impl;

import com.common.endpoint.MetricsEndpoint;
import com.common.helper.ActuatorHelper;
import com.system.service.ServerService;
import com.system.vo.response.Server;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ServerServiceImpl implements ServerService {

    @Autowired
    private ActuatorHelper actuatorHelper;

    @Override
    public List<Server> getServer(String name) {
        List<MetricsEndpoint.FebsMetricResponse> server = actuatorHelper.getMetricResponseByType(name);
        List<Server> servers = null;
        if (name.equals("tomcat"))
            servers =actuatorHelper.getTomcatInfoFromMetricData(server);
        else if (name.equals("jvm"))
            servers =actuatorHelper.getJvmInfoFromMetricData(server);
        return servers;
    }

}
